<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Titanic 项目详解 | Miki&#39;s blog</title>
  <meta name="keywords" content=" 机器学习 ">
  <meta name="description" content="Titanic 项目详解 | Miki&#39;s blog">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description" content="keywords: author: Miki language: zh-CN timezone:">
<meta property="og:type" content="website">
<meta property="og:title" content="标签">
<meta property="og:url" content="http://mikiblog.online/tags/index.html">
<meta property="og:site_name" content="Miki&#39;s blog">
<meta property="og:description" content="keywords: author: Miki language: zh-CN timezone:">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-02-22T01:48:02.000Z">
<meta property="article:modified_time" content="2020-02-22T01:50:40.651Z">
<meta property="article:author" content="Miki Zhu">
<meta name="twitter:card" content="summary">


<link rel="icon" href="/img/1.jpg">

<link href="/css/style.css?v=1.0.1" rel="stylesheet">

<link href="/css/hl_theme/atom-dark.css?v=1.0.1" rel="stylesheet">

<link href="//cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="/js/jquery.autocomplete.min.js?v=1.0.1" ></script>

<script src="//cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>
<script>
    hljs.initHighlightingOnLoad();
</script>

<script src="//cdn.bootcss.com/nprogress/0.2.0/nprogress.min.js"></script>



<script src="/js/iconfont.js?v=1.0.1" ></script>

<meta name="generator" content="Hexo 4.2.0"></head>
<div style="display: none">
  <input class="theme_disqus_on" value="false">
  <input class="theme_preload_comment" value="false">
  <input class="theme_blog_path" value="">
</div>

<body>
<aside class="nav">
    <div class="nav-left">
        <a href="/" class="avatar_target">
    <img class="avatar" src="/img/头像.jpg" />
</a>
<div class="author">
    <span>Miki Zhu</span>
</div>

<div class="icon">
    
        
    
        
        <a title="email" href="mailto:747876457@qq.com" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-email"></use>
                </svg>
            
        </a>
        
    
        
        <a title="qq" href="http://wpa.qq.com/msgrd?v=3&uin=747876457&site=qq&menu=yes" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-qq"></use>
                </svg>
            
        </a>
        
    
</div>




<ul>
    <li><div class="all active">全部文章<small>(29)</small></div></li>
    
        
            
            <li><div data-rel="机器学习">机器学习<small>(7)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="机器学习实战">机器学习实战<small>(3)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="项目实战">项目实战<small>(4)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="博客搭建">博客搭建<small>(2)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="算法">算法<small>(3)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="python教程">python教程<small>(1)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="学习网站推荐">学习网站推荐<small>(1)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="考研经验">考研经验<small>(1)</small></div>
                
            </li>
            
        
    
</ul>
<div class="left-bottom">
    <div class="menus">
    
    
    
    
    </div>
    <div><a class="about  " target="_blank" href="/about">关于</a></div>
</div>
<input type="hidden" id="yelog_site_posts_number" value="29">
<input type="hidden" id="yelog_site_word_count" value="62.1k">
<div style="display: none">
    <span id="busuanzi_value_site_uv"></span>
    <span id="busuanzi_value_site_pv"></span>
</div>

    </div>
    <div class="nav-right">
        <div class="friends-area">
    <div class="friends-title">
        友情链接
        <i class="back-title-list"></i>
    </div>
    <div class="friends-content">
        <ul>
            
        </ul>
    </div>
</div>
        <div class="title-list">
    <form onkeydown="if(event.keyCode === 13){return false;}">
        <input id="local-search-input" class="search" type="text" placeholder="Search..." />
        <i class="cross"></i>
        <span>
            <label for="tagswitch">Tags:</label>
            <input id="tagswitch" type="checkbox" style="display: none" />
            <i id="tagsWitchIcon"></i>
        </span>
    </form>
    <div class="tags-list">
    
    <li class="article-tag-list-item">
        <a class="color5">机器学习</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">算法</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">博客搭建</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">python</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">网站推荐</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">考研经验</a>
    </li>
    
    <div class="clearfix"></div>
</div>

    
    <nav id="title-list-nav">
        
        <a id="top" class="python教程 "
           href="/2020/04/03/python%E9%9D%A2%E8%AF%95%E9%A2%98/"
           data-tag="python"
           data-author="" >
            <span class="post-title" title="python面试题(不定期更新)">python面试题(不定期更新)</span>
            <span class="post-date" title="2020-04-03 21:14:43">2020/04/03</span>
        </a>
        
        <a id="top" class="考研经验 "
           href="/2020/02/20/%E8%80%83%E7%A0%94%E5%88%9D%E8%AF%95%E7%BB%8F%E9%AA%8C/"
           data-tag="考研经验"
           data-author="" >
            <span class="post-title" title="考研初试经验">考研初试经验</span>
            <span class="post-date" title="2020-02-20 19:33:48">2020/02/20</span>
        </a>
        
        <a  class="机器学习实战 "
           href="/2020/04/19/%E9%80%BB%E8%BE%91%E5%9B%9E%E5%BD%92%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="逻辑回归代码实现">逻辑回归代码实现</span>
            <span class="post-date" title="2020-04-19 21:09:25">2020/04/19</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/04/14/%E9%A9%AC%E5%B0%94%E5%8F%AF%E5%A4%AB%E9%93%BE/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="马尔可夫链">马尔可夫链</span>
            <span class="post-date" title="2020-04-14 19:09:29">2020/04/14</span>
        </a>
        
        <a  class="机器学习实战 "
           href="/2020/04/14/%E5%86%B3%E7%AD%96%E6%A0%91%E5%AE%9E%E6%88%98%E9%9A%90%E5%BD%A2%E7%9C%BC%E9%95%9C%E5%88%86%E7%B1%BB/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="决策树实战隐形眼镜分类">决策树实战隐形眼镜分类</span>
            <span class="post-date" title="2020-04-14 10:49:40">2020/04/14</span>
        </a>
        
        <a  class="机器学习实战 "
           href="/2020/04/12/KNN%E5%AE%9E%E6%88%98%E4%B9%8B%E6%B5%B7%E4%BC%A6%E7%BA%A6%E4%BC%9A/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="KNN实战之海伦约会">KNN实战之海伦约会</span>
            <span class="post-date" title="2020-04-12 08:22:12">2020/04/12</span>
        </a>
        
        <a  class="博客搭建 "
           href="/2020/04/08/hexo-%E4%B8%BB%E9%A2%98%E6%B7%BB%E5%8A%A0%E8%AF%84%E8%AE%BA/"
           data-tag="博客搭建"
           data-author="" >
            <span class="post-title" title="hexo 主题添加评论">hexo 主题添加评论</span>
            <span class="post-date" title="2020-04-08 21:43:26">2020/04/08</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/30/%E6%98%8E%E5%A4%A9%E4%BC%9A%E4%B8%8B%E9%9B%A8%E5%90%97%EF%BC%9F/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="明天会下雨吗？">明天会下雨吗？</span>
            <span class="post-date" title="2020-03-30 11:25:31">2020/03/30</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/23/%E5%86%B3%E7%AD%96%E6%A0%91%E5%AE%9E%E7%8E%B0Titanic-%E9%87%8D%E8%A6%81/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="决策树实现Titanic(重要)">决策树实现Titanic(重要)</span>
            <span class="post-date" title="2020-03-23 17:09:05">2020/03/23</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/21/Titanic-%E9%A1%B9%E7%9B%AE%E8%AF%A6%E8%A7%A3/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="Titanic 项目详解">Titanic 项目详解</span>
            <span class="post-date" title="2020-03-21 14:07:20">2020/03/21</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/19/kaggle%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="kaggle项目实战，Titanic analysis">kaggle项目实战，Titanic analysis</span>
            <span class="post-date" title="2020-03-19 10:08:13">2020/03/19</span>
        </a>
        
        <a  class=""
           href="/2020/03/17/Pytorch-%E6%90%AD%E5%BB%BA%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Pytorch 搭建神经网络">Pytorch 搭建神经网络</span>
            <span class="post-date" title="2020-03-17 14:56:16">2020/03/17</span>
        </a>
        
        <a  class=""
           href="/2020/03/16/CNN%E5%8E%9F%E7%90%86/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="CNN">CNN</span>
            <span class="post-date" title="2020-03-16 09:11:00">2020/03/16</span>
        </a>
        
        <a  class=""
           href="/2020/03/14/%E9%9A%8F%E6%9C%BA%E6%A3%AE%E6%9E%97%E5%92%8Ck%E5%9D%87%E5%80%BC/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="random forest and k means">random forest and k means</span>
            <span class="post-date" title="2020-03-14 16:29:22">2020/03/14</span>
        </a>
        
        <a  class=""
           href="/2020/03/13/%E6%94%AF%E6%8C%81%E5%90%91%E9%87%8F%E6%9C%BA%E7%AE%97%E6%B3%95/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="支持向量机">支持向量机</span>
            <span class="post-date" title="2020-03-13 20:53:20">2020/03/13</span>
        </a>
        
        <a  class=""
           href="/2020/03/11/Matplotlab/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="Matplotlab">Matplotlab</span>
            <span class="post-date" title="2020-03-11 10:13:20">2020/03/11</span>
        </a>
        
        <a  class=""
           href="/2020/03/10/pandas/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="pandas">pandas</span>
            <span class="post-date" title="2020-03-10 09:20:27">2020/03/10</span>
        </a>
        
        <a  class=""
           href="/2020/03/09/logical-regression/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="logical regression">logical regression</span>
            <span class="post-date" title="2020-03-09 20:30:33">2020/03/09</span>
        </a>
        
        <a  class="学习网站推荐 "
           href="/2020/03/08/%E5%AD%A6%E4%B9%A0%E7%BD%91%E7%AB%99%E6%88%96%E5%B7%A5%E5%85%B7%E6%8E%A8%E8%8D%90/"
           data-tag="网站推荐"
           data-author="" >
            <span class="post-title" title="学习网站或工具推荐">学习网站或工具推荐</span>
            <span class="post-date" title="2020-03-08 20:44:55">2020/03/08</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/08/%E8%B4%9D%E5%8F%B6%E6%96%AF%E5%88%86%E6%9E%90/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="贝叶斯分析">贝叶斯分析</span>
            <span class="post-date" title="2020-03-08 20:11:15">2020/03/08</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/08/numpy/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="numpy的使用">numpy的使用</span>
            <span class="post-date" title="2020-03-08 19:15:54">2020/03/08</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/07/%E5%86%B3%E7%AD%96%E6%A0%91/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="决策树">决策树</span>
            <span class="post-date" title="2020-03-07 19:27:38">2020/03/07</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/06/K-%E8%BF%91%E9%82%BB%E7%AE%97%E6%B3%95/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="K-近邻算法">K-近邻算法</span>
            <span class="post-date" title="2020-03-06 20:18:19">2020/03/06</span>
        </a>
        
        <a  class="算法 "
           href="/2020/03/05/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="排序算法">排序算法</span>
            <span class="post-date" title="2020-03-05 19:41:32">2020/03/05</span>
        </a>
        
        <a  class="算法 "
           href="/2020/03/04/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E6%97%B6%E9%97%B4%E5%A4%8D%E6%9D%82%E5%BA%A6/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="数据结构与时间复杂度">数据结构与时间复杂度</span>
            <span class="post-date" title="2020-03-04 21:00:32">2020/03/04</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/04/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E6%95%B0%E5%AD%A6%E5%9F%BA%E7%A1%80/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="机器学习数学基础">机器学习数学基础</span>
            <span class="post-date" title="2020-03-04 16:48:34">2020/03/04</span>
        </a>
        
        <a  class="算法 "
           href="/2020/03/03/leetcode%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="哈希图 and 移动窗口">哈希图 and 移动窗口</span>
            <span class="post-date" title="2020-03-03 18:49:52">2020/03/03</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/01/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E5%9F%BA%E6%9C%AC%E6%9C%AF%E8%AF%AD/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="1 零基础学机器学习">1 零基础学机器学习</span>
            <span class="post-date" title="2020-03-01 20:23:40">2020/03/01</span>
        </a>
        
        <a  class="博客搭建 "
           href="/2020/02/20/Windows%E7%B3%BB%E7%BB%9F%E4%B8%8B%E7%94%A8hexo%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/"
           data-tag="博客搭建"
           data-author="" >
            <span class="post-title" title="Windows系统下用hexo搭建个人博客">Windows系统下用hexo搭建个人博客</span>
            <span class="post-date" title="2020-02-20 13:15:25">2020/02/20</span>
        </a>
        
    </nav>
</div>
    </div>
    <div class="hide-list">
        <div class="semicircle">
            <div class="brackets first"><</div>
            <div class="brackets">&gt;</div>
        </div>
    </div>
</aside>
<div class="post">
    <div class="pjax">
        <article id="post-Titanic-项目详解" class="article article-type-post" itemscope itemprop="blogPost">
    
        <h1 class="article-title">Titanic 项目详解</h1>
    
    <div class="article-meta">
        
        
        
        <span class="book">
            
                <a  data-rel="项目实战">项目实战</a>
            
        </span>
        
        
        <span class="tag">
            
            <a class="color5">机器学习</a>
            
        </span>
        
    </div>
    <div class="article-meta">
        
        创建时间:<time class="date" title='更新时间: 2020-03-22 20:33:27'>2020-03-21 14:07</time>
        
    </div>
    <div class="article-meta">
        
        <span>字数:3.1k</span>
        
        
        <span id="busuanzi_container_page_pv">
            阅读:<span id="busuanzi_value_page_pv">
                <span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </span>
        </span>
        
        
        <span class="top-comment" title="跳转至评论区">
            <a href="#comments">
                评论:<span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </a>
        </span>
        
    </div>
    
    <div class="toc-ref">
    
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#问题分析流程"><span class="toc-text"> 问题分析流程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#代码部分"><span class="toc-text"> 代码部分</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#读取数据read_csv"><span class="toc-text"> 读取数据read_csv()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#获取标签columnsvalues"><span class="toc-text"> 获取标签.columns.values</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#打印数据前几行或后几行的内容head"><span class="toc-text"> 打印数据前几行或后几行的内容.head()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#获取数据信息查看哪些数据有缺失info"><span class="toc-text"> 获取数据信息(查看哪些数据有缺失).info()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#分析数据的数字特征describepercentilesinclude"><span class="toc-text"> 分析数据的数字特征.describe(percentiles&#x3D;,include&#x3D;)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#特征筛选"><span class="toc-text"> 特征筛选</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#相关性测试重要groupby"><span class="toc-text"> 相关性测试(重要).groupby()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#计算相关性"><span class="toc-text"> 计算相关性</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#处理数据"><span class="toc-text"> 处理数据</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#删除某一行或某一列数据drop"><span class="toc-text"> 删除某一行或某一列数据drop()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#增加新的变量extract"><span class="toc-text"> 增加新的变量extract()</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#统计出现频率crosstab"><span class="toc-text"> 统计出现频率crosstab()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#数据替换replace"><span class="toc-text"> 数据替换replace()</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#将字符串数据转换成数值型map函数"><span class="toc-text"> 将字符串数据转换成数值型map()函数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#数据填充fillna"><span class="toc-text"> 数据填充fillna()</span></a></li></ol></li></ol>
    
<style>
    .left-col .switch-btn,
    .left-col .switch-area {
        display: none;
    }
    .toc-level-3 i,
    .toc-level-3 ol {
        display: none !important;
    }
</style>
</div>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>最近不打算更新博客，该把毕业论文和之前的笔记好好整理吸收下，打牢基础！！</p>
<p>我希望，这些笔记，以后能够当成参考书一样，方便查阅</p>
<p>​																			&gt;_&lt;</p>
<p>本篇主要对泰坦尼克号实战的详细原理解释，和对其他人的优秀代码分析</p>
<blockquote>
<p>提交了代码，预测准确度最后只有0.736，因此来看看别人的优秀代码，分析自己的不足</p>
</blockquote>
<h2 id="问题分析流程"><a class="markdownIt-Anchor" href="#问题分析流程"></a> 问题分析流程</h2>
<ol>
<li>获取数据，以任何方式</li>
<li>分析问题，比如说将实际问题归类为二分类的问题，选择合适的算法</li>
<li>数据转化，有些数据是以字符串的形式，因此要转换成数字，方便计算机处理，<strong>数据要如何进行转换，取决于你选择的算法</strong></li>
<li>填充数据值，因为获取的数据，某些样本的数据可能有部分缺失，或者不完整，我们可以用整体样本平均值或者将这一行数据删除</li>
<li>删除某些错误的数据</li>
<li>分析数据，进行特征工程分析（相关性分析），判断哪些特征对结果的影响比较大</li>
<li>分析能否创造一些新的有关特征，这些特征对我们解决问题比较有帮助</li>
<li>将你的数据可视化</li>
</ol>
<h2 id="代码部分"><a class="markdownIt-Anchor" href="#代码部分"></a> 代码部分</h2>
<h3 id="读取数据read_csv"><a class="markdownIt-Anchor" href="#读取数据read_csv"></a> 读取数据<code>read_csv()</code></h3>
<pre class="highlight"><code class="">import numpy as np
import pandas as pd

train_data = pd.read_csv(r'C:\Users\asus\Desktop\train.csv')
test_data = pd.read_csv(r'C:\Users\asus\Desktop\test.csv')
combine = [train_data, test_data]
print(combine[0])
#print(combine[0].shape)
</code></pre>
<pre class="highlight"><code class="">     PassengerId  Survived  Pclass  ...     Fare Cabin  Embarked
0              1         0       3  ...   7.2500   NaN         S
1              2         1       1  ...  71.2833   C85         C

(891, 12)
</code></pre>
<h3 id="获取标签columnsvalues"><a class="markdownIt-Anchor" href="#获取标签columnsvalues"></a> 获取标签<code>.columns.values</code></h3>
<pre class="highlight"><code class="">print(train_data.columns.values)
</code></pre>
<pre class="highlight"><code class="">['PassengerId' 'Survived' 'Pclass' 'Name' 'Sex' 'Age' 'SibSp' 'Parch'
 'Ticket' 'Fare' 'Cabin' 'Embarked']
</code></pre>
<blockquote>
<p><strong>参数说明</strong></p>
<p><strong>pclass</strong>: A proxy for socio-economic status (SES)<br />
1st = Upper<br />
2nd = Middle<br />
3rd = Lower</p>
<p><strong>age</strong>: Age is fractional if less than 1. If the age is estimated, is it in the form of xx.5</p>
<p><strong>sibsp</strong>: The dataset defines family relations in this way…<br />
Sibling = brother, sister, stepbrother, stepsister<br />
Spouse = husband, wife (mistresses and fiancés were ignored)</p>
<p><strong>parch</strong>: The dataset defines family relations in this way…<br />
Parent = mother, father<br />
Child = daughter, son, stepdaughter, stepson<br />
Some children travelled only with a nanny, therefore parch=0 for them.</p>
</blockquote>
<h3 id="打印数据前几行或后几行的内容head"><a class="markdownIt-Anchor" href="#打印数据前几行或后几行的内容head"></a> 打印数据前几行或后几行的内容<code>.head()</code></h3>
<pre class="highlight"><code class="">train_data.head(5)
# 打印前5行内容
train_data.tail()
# 打印后几行内容
</code></pre>
<h3 id="获取数据信息查看哪些数据有缺失info"><a class="markdownIt-Anchor" href="#获取数据信息查看哪些数据有缺失info"></a> 获取数据信息(查看哪些数据有缺失)<code>.info()</code></h3>
<p><strong>通过这种方法查看数据缺失值</strong></p>
<pre class="highlight"><code class="">print(train_data.info())
print('-'*40)
print(test_data.info())
</code></pre>
<pre class="highlight"><code class="">&lt;class 'pandas.core.frame.DataFrame'&gt;
RangeIndex: 891 entries, 0 to 890
Data columns (total 12 columns):
PassengerId    891 non-null int64
Survived       891 non-null int64
Pclass         891 non-null int64
Name           891 non-null object
Sex            891 non-null object
Age            714 non-null float64
SibSp          891 non-null int64
Parch          891 non-null int64
Ticket         891 non-null object
Fare           891 non-null float64
Cabin          204 non-null object
Embarked       889 non-null object
dtypes: float64(2), int64(5), object(5)
memory usage: 83.7+ KB
None
----------------------------------------
&lt;class 'pandas.core.frame.DataFrame'&gt;
RangeIndex: 418 entries, 0 to 417
Data columns (total 11 columns):
PassengerId    418 non-null int64
Pclass         418 non-null int64
Name           418 non-null object
Sex            418 non-null object
Age            332 non-null float64
SibSp          418 non-null int64
Parch          418 non-null int64
Ticket         418 non-null object
Fare           417 non-null float64
Cabin          91 non-null object
Embarked       418 non-null object
dtypes: float64(2), int64(4), object(5)
memory usage: 36.0+ KB
None
</code></pre>
<h3 id="分析数据的数字特征describepercentilesinclude"><a class="markdownIt-Anchor" href="#分析数据的数字特征describepercentilesinclude"></a> 分析数据的数字特征<code>.describe(percentiles=,include=)</code></h3>
<pre class="highlight"><code class="">print(train_data.describe().iloc[:,1:])
</code></pre>
<pre class="highlight"><code class="">         Survived      Pclass         Age       SibSp       Parch        Fare
count  891.000000  891.000000  714.000000  891.000000  891.000000  891.000000
mean     0.383838    2.308642   29.699118    0.523008    0.381594   32.204208
std      0.486592    0.836071   14.526497    1.102743    0.806057   49.693429
min      0.000000    1.000000    0.420000    0.000000    0.000000    0.000000
25%      0.000000    2.000000   20.125000    0.000000    0.000000    7.910400
50%      0.000000    3.000000   28.000000    0.000000    0.000000   14.454200
75%      1.000000    3.000000   38.000000    1.000000    0.000000   31.000000
max      1.000000    3.000000   80.000000    8.000000    6.000000  512.329200
</code></pre>
<p><code>describe()</code>的参数说明</p>
<ol>
<li>
<p><code>train_data.describe(percentiles=[.8, .7])</code>表示可以输出80%和70%大的数字,直接这样描述,会<strong>只显示数字特征</strong></p>
</li>
<li>
<p><code>train_data.describe(include=['O'])</code>注意里面是大写的英文字母<code>O</code>,<strong>能输出非数字类型的数据特征</strong></p>
<ul>
<li>count：同上</li>
<li>unique：表示有多少种不同的值</li>
<li>top：数据中出现次数最高的值</li>
<li>freq：出现次数最高的那个值（top）的出现频率</li>
</ul>
</li>
</ol>
<pre class="highlight"><code class="">50%      0.000000    3.000000   28.000000    0.000000    0.000000   14.454200
70%      1.000000    3.000000   36.000000    1.000000    0.000000   27.000000
80%      1.000000    3.000000   41.000000    1.000000    1.000000   39.687500
max      1.000000    3.000000   80.000000    8.000000    6.000000  512.329200
</code></pre>
<pre class="highlight"><code class="">                        Name   Sex Ticket Cabin Embarked
count                    891   891    891   204      889
unique                   891     2    681   147        3
top     O'Brien, Mr. Timothy  male   1601    G6        S
freq                       1   577      7     4      644
</code></pre>
<p><strong>从中我们可以得到一些数字特征:</strong></p>
<p><strong>方差:当数据之间值差别比较大时,方差就比较大,虽然两组数据可能平均值一样</strong></p>
<ol>
<li>训练样本中大约有38%的人活下来了</li>
<li><code>Pclass</code>中1表示上等阶级,2表示中等阶级,我们可以发现高等阶级比较少</li>
<li>&gt;=75%的人,年龄都小于38岁</li>
<li>大部分人的票价,都比较低</li>
<li>带兄弟姐妹和家庭成员上船的还是比较多的</li>
</ol>
<hr />
<ol>
<li>名字是唯一的,没有人有相同的名字</li>
<li>性别只有两种,女性出现的次数比较多</li>
<li>有人共用船仓</li>
<li>大多数人的登陆地点为S</li>
</ol>
<h3 id="特征筛选"><a class="markdownIt-Anchor" href="#特征筛选"></a> 特征筛选</h3>
<p><strong>对特征进行假设</strong></p>
<ol>
<li>假设年龄和生存率相关</li>
<li>假设登录地点和生存率相关</li>
</ol>
<p><strong>我们可能假设一些人生存几率比较大</strong></p>
<ol>
<li>女性的生存概率比男性的要大</li>
<li>Age&lt;?的孩子,生存率要大</li>
<li>upper-class,生存率要高</li>
</ol>
<p><strong>删除一些特征</strong></p>
<ol>
<li>船舱重复率比较高,而且数据缺失值较大,所以删除</li>
<li><code>PassengerID</code>只是用来标记的,对生存没什么影响</li>
<li>船票特征的重复率也比较高,所以我们也进行删除</li>
</ol>
<p><strong>增加一些新的特征</strong></p>
<ol>
<li>创建一个家庭特征,有些人带了亲人,或者一些情侣</li>
<li>由于名字是唯一的,其中表示了一些人的身份,可以从名字中提取特征</li>
<li>设置一个年龄段,这个年龄段的生存率要高一些</li>
</ol>
<h3 id="相关性测试重要groupby"><a class="markdownIt-Anchor" href="#相关性测试重要groupby"></a> 相关性测试(重要)<code>.groupby()</code></h3>
<p><strong>先介绍下pandas中的<code>groupby</code>函数的用法</strong></p>
<p><code>gorupby()</code>表示按什么进行分类</p>
<p>假设有下面<code>DataFrame</code>数据</p>
<pre class="highlight"><code class="">          Sex  Age
xiao1    male   38
xiao2  female   55
xiao3  female   44
xiao4  female   43
</code></pre>
<p>输入下面代码：</p>
<pre class="highlight"><code class="">print(df.groupby('Sex').describe())
</code></pre>
<p>输出：</p>
<pre class="highlight"><code class="">         Age                                                   
       count       mean       std   min   25%   50%   75%   max
Sex                                                            
female   3.0  47.333333  6.658328  43.0  43.5  44.0  49.5  55.0
male     1.0  38.000000       NaN  38.0  38.0  38.0  38.0  38.0
</code></pre>
<blockquote>
<p>表示对<code>DataFrame</code>中的数据，按Sex属性进行分组统计，统计的是Age的特征</p>
</blockquote>
<p><strong>假设加了一列属性</strong></p>
<pre class="highlight"><code class="">          Sex  Age  num
xiao1    male   38    1
xiao2  female   55    2
xiao3  female   44    3
xiao4  female   43    4
</code></pre>
<p><strong>输出：按Sex分组，统计<code>Age</code>和<code>num</code>的mean and std等信息</strong></p>
<pre class="highlight"><code class="">         Age                                   ...  num                    
       count       mean       std   min   25%  ...  min  25%  50%  75%  max
Sex                                            ...                         
female   3.0  47.333333  6.658328  43.0  43.5  ...  2.0  2.5  3.0  3.5  4.0
male     1.0  38.000000       NaN  38.0  38.0  ...  1.0  1.0  1.0  1.0  1.0
</code></pre>
<p><strong>当我们只想要统计Age信息时候</strong>，可进行下面这样修改</p>
<pre class="highlight"><code class="">print(df.groupby('Sex')['Age'].describe())
</code></pre>
<p><strong>输出：</strong></p>
<pre class="highlight"><code class="">        count       mean       std   min   25%   50%   75%   max
Sex                                                             
female    3.0  47.333333  6.658328  43.0  43.5  44.0  49.5  55.0
male      1.0  38.000000       NaN  38.0  38.0  38.0  38.0  38.0
</code></pre>
<p><strong>多类分组：</strong></p>
<pre class="highlight"><code class="">print(df.groupby(['Sex','Age']).describe())
</code></pre>
<blockquote>
<p>表示且关系，满足性别的所有女生归为一类</p>
</blockquote>
<pre class="highlight"><code class="">             num                                  
           count mean std  min  25%  50%  75%  max
Sex    Age                                        
female 43    1.0  4.0 NaN  4.0  4.0  4.0  4.0  4.0
       44    1.0  3.0 NaN  3.0  3.0  3.0  3.0  3.0
       55    1.0  2.0 NaN  2.0  2.0  2.0  2.0  2.0
male   38    1.0  1.0 NaN  1.0  1.0  1.0  1.0  1.0
</code></pre>
<p><strong>获得平均值</strong></p>
<blockquote>
<p>如法炮制，还可以获得std，min等属性</p>
</blockquote>
<pre class="highlight"><code class="">print(df.groupby(['Sex','Age']).mean())
</code></pre>
<pre class="highlight"><code class="">            num
Sex    Age     
female 43     4
       44     3
       55     2
male   38     1
</code></pre>
<p><strong><code>as_index=</code>的用法</strong>(不改变索引)</p>
<pre class="highlight"><code class="">print(df.groupby(['Sex','Age'],as_index=True).mean())
print(df.groupby(['Sex','Age'], as_index=False).mean())
</code></pre>
<p>输出：</p>
<pre class="highlight"><code class="">            num
Sex    Age     
female 43     4
       44     3
       55     2
male   38     1

      Sex  Age  num
0  female   43    4
1  female   44    3
2  female   55    2
3    male   38    1
</code></pre>
<ul>
<li>注意<code>groupby</code>不能针对字符串类型使用</li>
</ul>
<h3 id="计算相关性"><a class="markdownIt-Anchor" href="#计算相关性"></a> 计算相关性</h3>
<p><strong>假设我们有一组数据</strong></p>
<pre class="highlight"><code class="">      Sex  Age  num
xiao1   0   38    1
xiao2   1   55    2
xiao3   1   41    2
xiao4   1   43    4
</code></pre>
<p><strong>输入下列指令</strong>,计算平均值</p>
<pre class="highlight"><code class="">print(df.loc[:,['Sex','Age']].groupby(&quot;Sex&quot;, as_index=False).mean())
</code></pre>
<pre class="highlight"><code class="">  Sex        Age
0   0  38.000000
1   1  46.333333
</code></pre>
<blockquote>
<p>该指令的意思是只按性别和年龄两列属性统计，按照性别进行分组，我们假设0为男性，1为女性，则男性年龄的平均值为38*1，女性平均值(55+41+43)/3</p>
</blockquote>
<pre class="highlight"><code class="">print(train_data.loc[:,['Survived', 'Pclass']].groupby(['Pclass'], as_index=True).mean())
</code></pre>
<pre class="highlight"><code class="">        Survived
Pclass          
1       0.629630
2       0.472826
3       0.242363
</code></pre>
<p>说明上等阶级中，所有存活的为1加起来，然后除以上等阶级总人数(上等阶级中，有60%的人活下来了)，中等阶级中接近50%的人活下来了，下等阶级中，只有25%的人活下来了</p>
<pre class="highlight"><code class="">print(train_data.loc[:,['Survived', 'Sex']].groupby(['Sex'], as_index=True).mean())
</code></pre>
<pre class="highlight"><code class="">        Survived
Sex             
female  0.742038
male    0.188908
</code></pre>
<p>同理可以看出，女性中，70%的人活下来了，男性中19%的人活下来了</p>
<h2 id="处理数据"><a class="markdownIt-Anchor" href="#处理数据"></a> 处理数据</h2>
<h3 id="删除某一行或某一列数据drop"><a class="markdownIt-Anchor" href="#删除某一行或某一列数据drop"></a> 删除某一行或某一列数据<code>drop()</code></h3>
<p><strong><code>drop()</code>函数，它不改变原有的<code>df</code>中的数据，而是返回另一个<code>dataframe</code>来存放删除后的数据。</strong></p>
<p><a href="https://blog.csdn.net/nuaadot/article/details/78304642" target="_blank" rel="noopener">参考</a></p>
<pre class="highlight"><code class="">print frame.drop(['a'])
print frame.drop(['Ohio'], axis = 1)
</code></pre>
<p>drop函数默认删除行，列需要加axis = 1</p>
<p><strong>采用drop方法，有下面三种等价的表达式：</strong></p>
<pre class="highlight"><code class="">1. DF= DF.drop('column_name', axis=1)；
2. DF.drop('column_name',axis=1, inplace=True)
3. DF.drop([DF.columns[[0,1, 3]]], axis=1, inplace=True)   # Note: zero indexed
</code></pre>
<p>注意：<strong>凡是会对原数组作出修改并返回一个新数组的，往往都有一个<code>inplace</code>可选参数。如果手动设定为True（默认为False）</strong>，那么原数组直接就被替换。也就是说，采用<code>inplace=True</code>之后，原数组名（如2和3情况所示）对应的内存值直接改变</p>
<pre class="highlight"><code class="">train_data, test_data =\
    train_data.drop(['Ticket', 'Cabin'], axis=1), test_data.drop(['Ticket', 'Cabin'], axis=1)
print(train_data.shape, test_data.shape)
</code></pre>
<p>输出：测试集比训练集少了是否生存这一个标签</p>
<pre class="highlight"><code class="">(891, 10) (418, 9)
</code></pre>
<h3 id="增加新的变量extract"><a class="markdownIt-Anchor" href="#增加新的变量extract"></a> 增加新的变量<code>extract()</code></h3>
<p><strong>使用正则将名字中的标签提取出来</strong><code>.</code>，要转义，否则就是表示任意字符</p>
<pre class="highlight"><code class="">r = re.compile(r' (.*?)\.', re.S)
print(re.search(r, each).group(1))
</code></pre>
<pre class="highlight"><code class="">Mr
Mrs
Miss
</code></pre>
<blockquote>
<p>由于正则要很多操作，比较麻烦，所以这里用extract函数，直接一步搞定</p>
</blockquote>
<p>expand=True在一组返回值的情况下，返回数据框</p>
<p>expand=False在一组返回值的情况下，返回序列(Series)</p>
<pre class="highlight"><code class="">     0    # 返回数据框
0    1
1    2
2  NaN		
</code></pre>
<pre class="highlight"><code class="">0      1  # 不返回数据框
1      2
2    NaN
</code></pre>
<p><strong>输入代码</strong>,可以看到直接完成</p>
<pre class="highlight"><code class="">train_data['Title'] = train_data.Name.str.extract(r' (.*?)\.', expand=False)
print(train_data.Title)
</code></pre>
<pre class="highlight"><code class="">0        Mr
1       Mrs
2      Miss
3       Mrs
</code></pre>
<p>我们需要同时对训练集和测试集进行操作</p>
<pre class="highlight"><code class="">train_data['Title'] = train_data.Name.str.extract(r' (.*?)\.', expand=False)
test_data['Title'] = test_data.Name.str.extract(r' (.*?)\.', expand=False)
</code></pre>
<h2 id="统计出现频率crosstab"><a class="markdownIt-Anchor" href="#统计出现频率crosstab"></a> 统计出现频率<code>crosstab()</code></h2>
<p><code>crosstab([],[])</code>, 左边是行，右边是列，可以是数组，也可以不是，行表示特征1，列表示特征2，整个结果为特征1元素在特征2中出现的频率</p>
<pre class="highlight"><code class="">print(pd.crosstab(train_data.Title,train_data.Survived))
</code></pre>
<pre class="highlight"><code class="">Survived        0    1
Title                 
Capt            1    0
Col             1    1
Don             1    0
Dr              4    3
Jonkheer        1    0
</code></pre>
<h2 id="数据替换replace"><a class="markdownIt-Anchor" href="#数据替换replace"></a> 数据替换<code>replace()</code></h2>
<pre class="highlight"><code class="">train_data['Title'] = train_data['Title'].replace(['Lady', 'Countess','Capt', 'Col',
 	'Don', 'Dr', 'Major', 'Rev', 'Sir', 'Jonkheer', 'Dona'], 'Rare')
test_data['Title'] = test_data['Title'].replace(['Lady', 'Countess','Capt', 'Col',
 	'Don', 'Dr', 'Major', 'Rev', 'Sir', 'Jonkheer', 'Dona'], 'Rare')
</code></pre>
<ul>
<li>我们将一些出现频率比较低的，都替换为一类</li>
</ul>
<pre class="highlight"><code class="">train_data.drop(train_data.Title[train_data.Title == 'the Countess'].index, inplace=True)
</code></pre>
<blockquote>
<p>这里之前正则处理的姓名有一个出了问题，于是把这个数据进行删除，利用布尔运算，得到一个Series，然后利用其index属性得到行数，再进行删除，如果<code>inplace</code>不设置，则不会改变原先的数据</p>
</blockquote>
<h3 id="将字符串数据转换成数值型map函数"><a class="markdownIt-Anchor" href="#将字符串数据转换成数值型map函数"></a> 将字符串数据转换成数值型<code>map()</code>函数</h3>
<pre class="highlight"><code class="">title_mapping = {&quot;Mr&quot;: 1, &quot;Miss&quot;: 2, &quot;Mrs&quot;: 3, &quot;Master&quot;: 4, &quot;Rare&quot;: 5}
train_data.Title = train_data.Title.map(title_mapping)
print(train_data.Title)
</code></pre>
<pre class="highlight"><code class="">0      1
1      3
2      2
</code></pre>
<p>可以看到将<code>{&quot;Mr&quot;: 1, &quot;Miss&quot;: 2, &quot;Mrs&quot;: 3, &quot;Master&quot;: 4, &quot;Rare&quot;: 5}</code>字典中有的，都转换成了对应的数字</p>
<p>注意：</p>
<p><strong>当数据中没有对应的键时，其原有数据就会被替换成<code>NaN</code></strong></p>
<h3 id="数据填充fillna"><a class="markdownIt-Anchor" href="#数据填充fillna"></a> 数据填充<code>fillna()</code></h3>
<p><code>.fillna(填充值)</code></p>
<pre class="highlight"><code class="">train_data['Age'] = train_data['Age'].fillna(train_data['Age'].median())
print(train_data['Age'].median())
</code></pre>

      
       
    </div>
</article>



<div class="article_copyright">
    <p><span class="copy-title">文章标题:</span>Titanic 项目详解</p>
    <p><span class="copy-title">文章字数:</span><span class="post-count">3.1k</span></p>
    <p><span class="copy-title">本文作者:</span><a  title="Miki Zhu">Miki Zhu</a></p>
    <p><span class="copy-title">发布时间:</span>2020-03-21, 14:07:20</p>
    <p><span class="copy-title">最后更新:</span>2020-03-22, 20:33:27</p>
    <span class="copy-title">原始链接:</span><a class="post-url" href="/2020/03/21/Titanic-%E9%A1%B9%E7%9B%AE%E8%AF%A6%E8%A7%A3/" title="Titanic 项目详解">http://mikiblog.online/2020/03/21/Titanic-%E9%A1%B9%E7%9B%AE%E8%AF%A6%E8%A7%A3/</a>
    <p>
        <span class="copy-title">版权声明:</span><i class="fa fa-creative-commons"></i> <a rel="license noopener" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
    </p>
</div>



    <div id="vcomment" class="comment"></div> 
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<script src="https://cdnjs.loli.net/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
    var notify = 'false' == true ? true : false;
    var verify = 'false' == true ? true : false;
    new Valine({
        av: AV,
        el: '#vcomment',
        notify: notify,
        app_id: "3uM9nFQKJdCUOHqwT3LHL5Mt-gzGzoHsz",
        app_key: "3v4CdFJJjh97olrmyHxtdDlt",
        placeholder: "请输入",
        avatar:"mm",
    });
</script>



    





  <section id="comments" class="vcomment">
  </section>

    </div>
    <div class="copyright">
        <p class="footer-entry">©2016-2019 MikiZhu 赣ICP备20004640号</p>
<p class="footer-entry">Built with <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/yelog/hexo-theme-3-hexo" target="_blank">3-hexo</a> theme</p>

    </div>
    <div class="full-toc">
        <button class="full"><span class="min "></span></button>
<button class="post-toc-menu"><span class="post-toc-menu-icons"></span></button>
<div class="post-toc"><span class="post-toc-title">目录</span>
    <div class="post-toc-content">

    </div>
</div>
<a class="" id="rocket" ></a>

    </div>
</div>
<div class="acParent"></div>

</body>
<script src="/js/jquery.pjax.js?v=1.0.1" ></script>

<script src="/js/script.js?v=1.0.1" ></script>
<script>
    var img_resize = 'default';
    /*作者、标签的自动补全*/
    $(function () {
        $('.search').AutoComplete({
            'data': ['#机器学习','#算法','#博客搭建','#python','#网站推荐','#考研经验',],
            'itemHeight': 20,
            'width': 418
        }).AutoComplete('show');
    })
    function initArticle() {
        /*渲染对应的表格样式*/
        
            $(".post .pjax table").addClass("green_title");
        

        /*渲染打赏样式*/
        

        /*高亮代码块行号*/
        

        /*访问数量*/
        
        $.getScript("//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js");
        

        /*代码高亮，行号对齐*/
        $('.pre-numbering').css('line-height',$('.has-numbering').css('line-height'));

        
        
    }

    /*打赏页面隐藏与展示*/
    

</script>

<!--加入行号的高亮代码块样式-->

<!--自定义样式设置-->
<style>
    
    
    .nav {
        width: 542px;
    }
    .nav.fullscreen {
        margin-left: -542px;
    }
    .nav-left {
        width: 120px;
    }
    
    
    @media screen and (max-width: 1468px) {
        .nav {
            width: 492px;
        }
        .nav.fullscreen {
            margin-left: -492px;
        }
        .nav-left {
            width: 100px;
        }
    }
    
    
    @media screen and (max-width: 1024px) {
        .nav {
            width: 492px;
            margin-left: -492px
        }
        .nav.fullscreen {
            margin-left: 0;
        }
        .nav .hide-list.fullscreen {
            left: 492px
        }
    }
    
    @media screen and (max-width: 426px) {
        .nav {
            width: 100%;
        }
        .nav-left {
            width: 100%;
        }
    }
    
    
    .nav-right .title-list nav a .post-title, .nav-right .title-list #local-search-result a .post-title {
        color: #383636;
    }
    
    
    .nav-right .title-list nav a .post-date, .nav-right .title-list #local-search-result a .post-date {
        color: #5e5e5f;
    }
    
    
    .nav-right nav a.hover, #local-search-result a.hover{
        background-color: #e2e0e0;
    }
    
    

    /*列表样式*/
    
    .post .pjax article .article-entry>ol, .post .pjax article .article-entry>ul, .post .pjax article>ol, .post .pjax article>ul{
        border: #e2dede solid 1px;
        border-radius: 10px;
        padding: 10px 32px 10px 56px;
    }
    .post .pjax article .article-entry li>ol, .post .pjax article .article-entry li>ul,.post .pjax article li>ol, .post .pjax article li>ul{
        padding-top: 5px;
        padding-bottom: 5px;
    }
    .post .pjax article .article-entry>ol>li, .post .pjax article .article-entry>ul>li,.post .pjax article>ol>li, .post .pjax article>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    .post .pjax article .article-entry li>ol>li, .post .pjax article .article-entry li>ul>li,.post .pjax article li>ol>li, .post .pjax article li>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    

    /* 背景图样式 */
    
    


    /*引用块样式*/
    

    /*文章列表背景图*/
    
    .nav-right:before {
        content: ' ';
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        opacity: 0.4;
        background: url("http://q8idlsxje.bkt.clouddn.com/%E6%B5%B7%E6%BB%A9.jpg");
        background-repeat: no-repeat;
        background-position: 50% 0;
        -ms-background-size: cover;
        -o-background-size: cover;
        -moz-background-size: cover;
        -webkit-background-size: cover;
        background-size: cover;
    }
    

    
</style>







  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  <script>
    var GUEST_INFO = ['nick','mail','link'];
    var guest_info = 'nick,mail,link'.split(',').filter(function(item){
        return GUEST_INFO.indexOf(item) > -1
    });
    var notify = 'false' == true;
    var verify = 'false' == true;
    new Valine({
      el: '.vcomment',
      notify: notify,
      verify: verify,
      appId: "3uM9nFQKJdCUOHqwT3LHL5Mt-gzGzoHsz",
      appKey: "3v4CdFJJjh97olrmyHxtdDlt",
      placeholder: "请输入",
      pageSize: '10',
      avatar: 'mm',
      lang: 'zh-cn',
      visitor: 'true'
    });
  </script>

</html>
